﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;

using System.IO;

namespace Lolitemchanger
{
    class CGestionIni
    {

            public string chemin_fichier_ini;


            [DllImport("kernel32")]
            private static extern long WritePrivateProfileString(string section, string cle, string valeur, string chemin_ini);

            [DllImport("kernel32")]
            private static extern int GetPrivateProfileString(string section, string cle, string valeur_defaut, StringBuilder valeur, int taille, string chemin_ini);

            public CGestionIni(string chemin_ini)
            {
                chemin_fichier_ini = chemin_ini;
            }

            public void StockerValeur(string section, string cle, string valeur)
            {
                WritePrivateProfileString(section, cle, valeur, this.chemin_fichier_ini);
            }


            public string RecupererValeur(string section, string cle)
            {
                StringBuilder temp_ini = new StringBuilder(255);
                GetPrivateProfileString(section, cle, "", temp_ini, 255, this.chemin_fichier_ini);
                return temp_ini.ToString();
            }


            public bool Exist()
            {
                if (File.Exists(this.chemin_fichier_ini))
                {
                    return true;
                }
                return false;

            }


        
    }
}
